package com.zcp.service;

import com.zcp.dao.StudentDAO;
import com.zcp.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class StudentServiceImpl implements StudentService{


    @Autowired
    private StudentDAO studentDAO;


    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<Student> finaAll() {
        return studentDAO.findAll();
    }

    @Override
    public List<Student> finaAll(String searchCol, String searchValue) {
        return studentDAO.find(searchCol,searchValue);
    }

    @Override
    public List<Student> finaAll(Integer pageNow, Integer rows, String searchCol, String searchValue) {
        int start = (pageNow-1)*rows;
        return studentDAO.findByLikePage(start,rows,searchCol,searchValue);
    }

    @Override
    public Integer totalCount(String searchCol, String searchValue) {
        return studentDAO.totalCount(searchCol,searchValue);
    }

    @Override
    public void save(Student Student) {
        studentDAO.save(Student);
    }

    @Override
    public Student change(Integer id) {
        return (Student) studentDAO.change(id);
    }

    @Override
    public void changed(Student student) {
        studentDAO.changed(student);
    }

    @Override
    public void delete(Integer id) {
        studentDAO.delete(id);
    }
}
